package com.wang.see.domain;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.wang.see.pojo.Image;

public interface ImageRepository extends JpaRepository<Image, String> {
	
	@Query(value="select a.img_name,a.img_path,a.img_folder_name from image a JOIN (select img_folder_name, MAX(img_path) mPath from image GROUP BY img_folder_name) b on a.img_folder_name = b.img_folder_name AND a.img_path = b.mPath LIMIT :page,:size",nativeQuery=true)
	List<Image> getImgFolder(@Param("page") Integer page,@Param("size") Integer size);

	@Query(value="select a.img_name,a.img_path,a.img_folder_name from image a JOIN (select img_folder_name, MAX(img_path) mPath from image GROUP BY img_folder_name) b on a.img_folder_name = b.img_folder_name AND a.img_path = b.mPath",nativeQuery=true)
	List<Image> getAllImgFolder();
	
	List<Image> findByImgFolderName(String imgFolderName);
	
	
}
